﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;
using ArxivatDeDocuments.Formularis;
using ArxivatDeDocuments.ObjectesDeDades;

namespace ArxivatDeDocuments.ObjectesDeNegoci
{
    class OmplirNomsInexistentsController : Controller
    {
        frmOmplirNomsInexistents frm;        
        List<Document> documentsTrobats;

        public OmplirNomsInexistentsController(List<Document> pDocumentsTrobats)
        {
            documentsTrobats = pDocumentsTrobats;
        }

        public override void run()
        {
            List<Client> clientsSenseNom = (from Client c in Contexte.getClients() where string.IsNullOrEmpty(c.Nom) select c).ToList<Client>();
            
            if (clientsSenseNom.Count() != 0)
            {
                frm = new frmOmplirNomsInexistents(clientsSenseNom);
                frm.ShowDialog();

                if (!frm.CancelPressed)
                {
                    foreach (Client c in clientsSenseNom)
                    {
                        if (!string.IsNullOrEmpty(c.Nom)) c.AddToFile();
                    }

                    this.ProximaAccio = enumProximaAccio.ProximPas;
                }
                else
                    this.ProximaAccio = enumProximaAccio.TancarPrograma;
            }
            else
                this.ProximaAccio = enumProximaAccio.ProximPas;
        }


    }

     
}
